from django.db import models


# Create your models here.

class User(models.Model):
    username = models.CharField('用户名', max_length=32)
    password = models.CharField('密码', max_length=32)

    class Meta:
        db_table = 'user'


class Goods(models.Model):
    title = models.CharField('商品名称', max_length=32)
    price = models.IntegerField('价格')
    img = models.ImageField(upload_to='static')
    buy_num = models.IntegerField('购买次数', default=0)
    comment_num = models.IntegerField('评论次数', default=0)

    class Meta:
        db_table = 'goods'


class Order(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    goods = models.ForeignKey(Goods, on_delete=models.CASCADE)
    comment = models.CharField('评论', max_length=256, default=None, null=True)
    is_comment = models.BooleanField('是否评论', default=False)

    class Meta:
        db_table = 'order'
